package com.tiancheng.trade.merchant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author liuzhonghu
 * @date 2024/4/3 16:00
 */
@Getter
@AllArgsConstructor
public enum MerchantScenarioEnum {
    HOTEL("1", "酒店"),
    FLIGHT("2", "机票"),
    TICKET("3", "门票"),
    LINE("4", "精品线路"),
    BUS_TICKET("5", "汽车票"),
    FREE("6", "自由行"),
    TRAFFIC("7", "交通"),
    CHARTERE("8", "包车"),
    CAR_HAILING("9", "网约车"),
    ETC("10", "ETC"),
    OFFICIAL_TRIP("11", "公务出行"),
    GUIDE("12", "达人带你游"),
    UNMANNED_SUPERMARKET("13", "无人超市"),
    TOURISM_INVESTMENT("14", "建水旅投"),
    GUIDE_NEW("15", "新达人带你游"),
    TOURISM_PACKAGES("16", "旅游套餐"),
    ERHAI_TICKET_WAREHOUSE("17", "洱海票仓"),
    NFT("18", "NFT数字藏品"),
    LIVE_REWARDS("19", "直播打赏"),
    YUN_PIN("20", "云品"),
    DRIVERLESS("90", "无人车"),
    CONSOLIDATION("99", "合单"),
    ;


    private final String code;
    private final String desc;

    public static String getDescByCode(String code) {
        return Arrays.stream(values()).filter(d -> Objects.equals(d.getCode(), code)).findFirst()
                .map(MerchantScenarioEnum::getDesc).orElse("");
    }

    /**
     * 根据code获取具体枚举，一般switch中使用
     *
     * @param code
     * @return
     */
    public static MerchantScenarioEnum getByCode(String code) {
        return Arrays.stream(values()).filter(d -> Objects.equals(d.getCode(), code)).findFirst().orElse(null);
    }
}
